package com.cen.cloud.service;

import com.cen.cloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author cen
 * @Date 2020/10/5 13:54
 */
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public boolean addDept(Dept dept) {
                return false;
            }

            @Override
            public List<Dept> getAll() {
                return null;
            }

            @Override
            public Dept getByID(Long deptno) {
                return new Dept().setDeptno(deptno)
                        .setDname("提供了降级服务")
                        .setDb_source("没有数据");
            }
        };
    }
}
